<template>
	<view>
		<!-- 轮播图 -->
		<view class="swiper-view">
			<u-swiper :list="list" :height="400" bg-color="#C62F23" border-radius="0"></u-swiper>
		</view>
		<!-- 邀请礼金 -->
		<view class="tips-view">
			<line-title name="邀请礼金"></line-title>
		</view>
		<!-- 邀请商品 -->
		<view class="tips-view">
			<shop-goodsa :list="giftList" isThreeViewList @goodsClick="receiveInvite"></shop-goodsa>
		</view>
	</view>
</template>

<script>
	import lineTitle from "@/components/title/line-title.vue"
	import shopGoodsa from "@/components/goods/shopGoodsa.vue"
	export default {
		components: {
			lineTitle,
			shopGoodsa
		},
		data() {
			return {
				list: ['../../../static/index/11.png', '../../../static/index/11.png'],
				giftList: []
			}
		},
		onShow() {
			this.getInvite()
		},
		methods: {
			getInvite(){
				this.$http.post(this.$api.getInvite,{},{token:true}).then(res=>{
					this.giftList = res.data.map(item=>{
						return {
							id:item.id,
							goods_image: "../../../static/index/22.png",
							goods_name: `邀请${item.num}位好友注册`,
							goods_desc: `${item.reward}元`,
							benName: "立即领取"
						}
					})
				})
			},
			receiveInvite(item){
				this.$http.post(this.$api.receiveInvite,{id:item.id},{token:true}).then(res=>{
					if(res.code == 1){
						this.$tools.toast('领取成功')
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.tips-view {
		padding: 30rpx;
	}
</style>